﻿<%@ Page Language="C#" MasterPageFile="~/Samples.master"  Codebehind="DataVisualization.aspx.cs"
	Inherits="Sample.DataVisualization" Title="Folks Data Visualization Sample" %>

<asp:Content ID="Content1" ContentPlaceHolderID="bodyContentPlaceHolder" runat="server">
	<div id="app">
		<h3>
			Data Visualization</h3>
		<asp:TextBox ID="filterTextBox" runat="server"></asp:TextBox>
		<asp:DropDownList ID="filterDropDownList" runat="server">
			<asp:ListItem>Name</asp:ListItem>
			<asp:ListItem>Email</asp:ListItem>
		</asp:DropDownList>
		<asp:Button ID="filterButton" runat="server" OnClick="filterButton_Click" Text="Filter"
			rel="folks" />
		<folks:FolksProgress ID="sampleFolksProgress" runat="server">
			<img src="Images/wait.gif" /></folks:FolksProgress>
		<folks:FolksContainer ID="dataContainer" runat="server" ProgressControlID="sampleFolksProgress">
			<asp:GridView ID="sampleGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False"
				PageSize="10" CellPadding="4" DataSourceID="sampleObjectDataSource" ForeColor="#333333"
				GridLines="None" rel="folks" Width="100%" AllowSorting="true">
				<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
				<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
				<Columns>
					<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ItemStyle-Width="50%" />
					<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-Width="50%" />
					<asp:CommandField ShowSelectButton="True" ItemStyle-Width="0%" />
				</Columns>
				<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
				<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
				<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="left" />
				<EditRowStyle BackColor="#999999" />
				<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
			</asp:GridView>
			<asp:ObjectDataSource ID="sampleObjectDataSource" runat="server" SelectMethod="GetDataTable"
				TypeName="Sample.Person"></asp:ObjectDataSource>
		</folks:FolksContainer>
	</div>
	<div id="aspx">
		<h4>ASPX</h4>
		<pre class="code_fixed sh_html">
&lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;asp:DropDownList ID="DropDownList1" runat="server"&gt;
	&lt;asp:ListItem&gt;Name&lt;/asp:ListItem&gt;
	&lt;asp:ListItem&gt;Email&lt;/asp:ListItem&gt;
&lt;/asp:DropDownList&gt;
&lt;asp:Button <strong>rel="folks" </strong>ID="Button1" runat="server" OnClick="filterButton_Click" Text="Filter" /&gt; <strong>
&lt;folks:FolksProgress ID="FolksProgress1" runat="server"&gt;</strong>
	&lt;img src="Images/wait.gif" /&gt;
<strong>&lt;/folks:FolksProgress&gt;</strong>
			<strong>
&lt;folks:FolksContainer ID="FolksContainer1" runat="server" ProgressControlID="sampleFolksProgress"&gt;</strong>
	&lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
		PageSize="10" CellPadding="4" DataSourceID="sampleObjectDataSource" ForeColor="#333333"
		GridLines="None" rel="folks" Width="100%" AllowSorting="true"&gt;
		&lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt;
		&lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt;
		&lt;Columns&gt;
			&lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" ItemStyle-Width="50%" /&gt;
			&lt;asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" ItemStyle-Width="50%" /&gt;
			&lt;asp:CommandField ShowSelectButton="True" ItemStyle-Width="0%" /&gt;
		&lt;/Columns&gt;
		&lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt;
		&lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt;
		&lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="left" /&gt;
		&lt;EditRowStyle BackColor="#999999" /&gt;
		&lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
	&lt;/asp:GridView&gt;
	&lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetDataTable"
		TypeName="Sample.Person"&gt;&lt;/asp:ObjectDataSource&gt;
			<strong>
&lt;/folks:FolksContainer&gt;</strong>
		</pre>
	</div>
	<div id="source">
		<h4>Source</h4>
		<pre class="code_fixed sh_csharp">
namespace Sample
{
	public partial class DataVisualization : System.Web.UI.Page
	{
		protected void filterButton_Click(object sender, EventArgs e)
		{
			System.Threading.Thread.Sleep(500);
			sampleObjectDataSource.FilterExpression = filterDropDownList.SelectedValue + " like '%" + filterTextBox.Text + "%'";
			sampleGridView.DataBind();
		}
	}

	public class Person
	{
		private static List<Person> persons;
		private static DataTable table;

		static Person()
		{
			persons = new List<Person>();
			for (int i = 0; i < 400; i++)
				persons.Add(new Person("Fulano" + i, "fulano" + i + "@folks.com"));

			table = new DataTable("Person");
			table.Columns.Add("Name");
			table.Columns.Add("Email");
		}

		public Person()
		{
		}

		public Person(string name, string email)
		{
			Name = name;
			Email = email;
		}

		private string name;

		public string Name
		{
			get { return name; }
			set { name = value; }
		}

		private string email;

		public string Email
		{
			get { return email; }
			set { email = value; }
		}

		public List<Person> GetList()
		{
			return persons;
		}

		public DataTable GetDataTable()
		{
			table.Clear();
			foreach (Person p in GetList())
			{
				DataRow row = table.NewRow();
				row["Name"] = p.Name;
				row["Email"] = p.Email;
				table.Rows.Add(row);
			}
			return table;
		}
	}
}
		</pre>
	</div>
</asp:Content>
